package cn.wolfcode.crm.service.impl;


import cn.wolfcode.crm.domain.DataDictionary;
import cn.wolfcode.crm.mapper.DataDictionaryMapper;
import cn.wolfcode.crm.query.ObjectQuery;
import cn.wolfcode.crm.query.PageResult;
import cn.wolfcode.crm.service.IDataDictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class DataDictionaryServiceImpl implements IDataDictionaryService {
    @Autowired
    private DataDictionaryMapper dataDistionaryMapper;
    //数据字典保存操作
    public void save(DataDictionary dataDistionary) {
        dataDistionaryMapper.save(dataDistionary);
    }

    public void delete(Long id) {
        dataDistionaryMapper.delete(id);

    }

    public void update(DataDictionary dataDistionary) {
        //保存更新后的部门
        dataDistionaryMapper.update(dataDistionary);
    }

    public DataDictionary get(Long id) {
        return dataDistionaryMapper.get(id);
    }

    public List<DataDictionary> getAll() {

        return dataDistionaryMapper.getAll();
    }

    public PageResult<DataDictionary> query(ObjectQuery qo) {
        int totalCount = dataDistionaryMapper.queryForCount(qo);
        if (totalCount == 0) {
            return new PageResult<DataDictionary>(totalCount, Collections.<DataDictionary>emptyList());
        }


        return new PageResult<DataDictionary>(totalCount,dataDistionaryMapper.queryForList(qo));
    }

    public List<DataDictionary> selectDataBySn(String sn) {
        List<DataDictionary> datas =  dataDistionaryMapper.selectDataBySn(sn);
        return datas;
    }

    @Override
    public List<DataDictionary> queryPayWayById() {
        return dataDistionaryMapper.queryPayWayById();
    }


}
